Skip to content

[#154] Add receipt fetch retry to indexer routes#162

Merged
realproject7 merged 1 commit intomainfrom
task/154-indexer-receipt-retry
Mar 16, 2026
Merged

[#154] Add receipt fetch retry to indexer routes#162
realproject7 merged 1 commit intomainfrom
task/154-indexer-receipt-retry

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Added getReceiptWithRetry helper in lib/rpc.ts — 3 attempts with 1s exponential backoff
  • Applied to all 3 indexer routes: /api/index/donation, /api/index/storyline, /api/index/plot
  • Switched routes from lib/viem (compat shim) to direct lib/rpc imports

Fixes #154

Test plan

  • tsc --noEmit — zero errors
  • next build — clean
  • vitest run — 22/22 tests pass
  • Trigger a donation/storyline/plot indexing immediately after tx confirms — should succeed instead of 502

🤖 Generated with Claude Code

Load-balanced RPC nodes may not have the receipt immediately after
waitForTransactionReceipt completes on the client. Added
getReceiptWithRetry helper (3 attempts, 1s backoff) and applied it
to all three indexer routes (donation, storyline, plot).

Fixes #154

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T2b APPROVE

Clean, minimal fix:

  1. getReceiptWithRetry (lib/rpc.ts) — Simple retry with linear backoff (1s, 2s, 3s). Properly re-throws on final attempt. Hex type import is correct.

  2. All 3 indexer routes updated consistently — donation, storyline, plot all switch from lib/viem shim to lib/rpc and use the retry helper. The existing catch → 502 error handling still applies if all retries fail.

No issues found.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The PR addresses the exact failure mode in #154 by retrying receipt reads in the indexer routes instead of failing immediately on the first stale RPC response. The helper is centralized in lib/rpc.ts, applied consistently to all three affected routes, and local validation plus CI are green.

Findings

  • [info] No remaining blocking findings.
    • File: lib/rpc.ts:26
    • Suggestion: None.

Decision

Approving because the change is narrowly scoped to the receipt-availability race, covers every affected indexer route, and passes lint-and-typecheck, typecheck, tests, and build validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Indexer race condition — 502 on receipt fetch after tx confirms

2 participants